﻿using LDT.CoreLibrary;
using LdtJudge.DataEngine.CallInterface;
using LdtJudge.DataEngine.Common;
using LdtJudge.DataEngine.Common.ConfigXmlLoad;
using LdtJudge.DataEngine.DataBaseStores;
using LdtJudge.DataEngine.Model;
using LdtJudge.DataEngine.Model.CommModel;
using LdtJudge.DataEngine.Model.DataModel.SysCommon;
using LdtJudge.DataEngine.Model.UnitModel;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Xml;

namespace Ldt.DataEngin.Assemble
{
    public class Main:MainBase
    {
        #region 声明基础信息

        public Main() 
        {
        
        }

        /// <summary>
        /// 声明基础参数
        /// </summary>
        /// <param name="caseType">案件类型 b1</param>
        /// <param name="courtID">法院</param>
        /// <param name="sD_CaseOnlyID">案件唯一ID</param>
        /// <param name="appId">应用ID</param>
        /// <param name="cCIDs">案由</param>
        /// <param name="caseID">案件ID</param>
        public void Loading(string caseType, string courtID, string sD_CaseOnlyID, string appId, string docType, string cCIDs = "", string caseID = "")
        {
            
            ////开始分析
            //LogShow("进入分析程序，caseType", LogMessageType.Debug);

            //#region 基础信息赋值
            //Dictionary<string, string> dicParmet = new Dictionary<string, string>();
            //dicParmet.Add("caseType", caseType.ToLower());
            //dicParmet.Add("appId", appId.ToLower());
            //dicParmet.Add("caseCause", cCIDs);
            //dynamicDataStores.dataLayerStores.caseType = caseType;
            //dynamicDataStores.dataLayerStores.courtId = courtID;
            //dynamicDataStores.dataLayerStores.caseCause = cCIDs;
            //dynamicDataStores.dataLayerStores.appId = appId;
            //dynamicDataStores.dataLayerStores.docID = docType;
            //if (!string.IsNullOrEmpty(caseID))
            //{
            //    dynamicDataStores.dataLayerStores.Caseid = caseID;
            //}
            //dynamicDataStores.dataLayerStores.Start();
            ////交互对象实现;
            //dynamicDataStores.InteractiveShow.LogShow = new LogShow(LogShow);//日志委托
            //dynamicDataStores.InteractiveShow.ProcessShow = new ProcessShow(SetProgress);//总体进度委托
            //dynamicDataStores.InteractiveShow.ModuleProcessShow = new ModuleProcessShow(SetModuleProcess);//模块进度委托
            //dynamicDataStores.InteractiveShow.Finishow = new FinishShow(FinishShow);//结束委托
            //// 案由提取
            //List<CaseCauseModel> caseCauses = new List<CaseCauseModel>();
            //CaseCauseExtract caseCauseExtract = new CaseCauseExtract() { dynamicDataStores = dynamicDataStores };
            //caseCauses = caseCauseExtract.CaseCauseExt();
            //dynamicDataStores.dataLayerStores.CaseCausesList = caseCauses;
            //dynamicDataStores.dataLayerStores.Caseid = caseID;
            //dynamicDataStores.dataLayerStores.SD_CaseOnlyID = sD_CaseOnlyID;
            //if (caseCauses != null && caseCauses.Count > 0)
            //{
            //    foreach (CaseCauseModel item in caseCauses)
            //    {
            //        if (string.IsNullOrEmpty(dynamicDataStores.dataLayerStores.caseCause))
            //            dynamicDataStores.dataLayerStores.caseCause = item.CC_Name;
            //        else
            //            dynamicDataStores.dataLayerStores.caseCause = item.CC_Name;
            //    }
            //}

            //dynamicDataStores.dataLayerStores.AnalysisParameter.AP_ApplactionID = appId;
            //dynamicDataStores.dataLayerStores.AnalysisParameter.AP_CaseType = caseType;
            //dynamicDataStores.dataLayerStores.AnalysisParameter.AP_SourceName = docType;
            //#endregion

            //#region 配置文件读取/转换
            ////优选配置转换
            //string messagexml = WebUtil.DoGet(configRetrieval.GetConnectionString("systemapi") + "/api/wordparse/GetOptimizeCfgInfo", dicParmet, "utf-8");
            //dynamic optimizatConifg = JsonConvert.DeserializeObject<dynamic>(messagexml);
            //if (optimizatConifg.result.code == "1")
            //{

            //    dicParmet["caseType"] = "b1";
            //    dicParmet["appId"] = "mscourtrecord";
            //    messagexml = WebUtil.DoGet(configRetrieval.GetConnectionString("systemapi") + "/api/wordparse/GetOptimizeCfgInfo", dicParmet, "utf-8");

            //    dynamic optimizatConifgmodel = JsonConvert.DeserializeObject<dynamic>(messagexml);
            //    if (optimizatConifgmodel.result.code == "0")
            //    {
            //        XmlMessage = HttpHelp.DeCodeBase64new(65001, optimizatConifgmodel.body.ToString());
            //    }

            //}
            //else
            //{
            //    XmlMessage = HttpHelp.DeCodeBase64new(65001, optimizatConifg.body.ToString());
            //}
            //#endregion
        }
        #endregion
    }
}
